import React, { useMemo } from 'react';
import clsname from '../lib/clsname';
const comClsName = `${clsname.name}-ofd-viewer`;
function OfdViewer(props) {
    const { invoice } = props;
    const ofd = useMemo(() => {
        return invoice?.attachmentFiles?.[0] || {}
    }, [invoice]);
    const iframeKey = invoice?.invoiceDataCode || new Date().valueOf();//如果没有发票编号，则用时间戳来代替key
    return (
        <div className={comClsName}>
            {ofd?.originalUrl ? <iframe
                className={"iframe-fullscreen-exit"}
                title="pdf"
                id={'iframe1'}
                key={iframeKey}
                src={invoice?.viewUrl || ofd.originalUrl}
            >
            </iframe> : null}
        </div >
    )
}
export default OfdViewer;